<?php

require_once CONTROLLER;

class controllerUhet extends Controller
{
	public function __construct(){
		
		parent::__construct();
	}
	
	public function index(){
		
		$view = $this->create('view','uhet');
		$view->index();
	}
	
	public function listar(){
	
		$this->createView()->listar($this->createDao()->listar());
	}
	
	public function adicionar(){

		$this->createView()->adicionar();
	}
	
	public function find($parametros){
		
		$modelMateria = $this->createDao();
		$dbConfig = new dbConfig($parametros);
		//$dbConfig->loadArrayConfig($parametros);

		print_r($dbConfig);

		$objectMateriaArray = $modelMateria->find($dbConfig);
		print_r($objectMateriaArray);
	}
	
	public function json_listar(){
		
		
		$objectMateriaArray = $this->createDao('Materia')->findall();
		
		$json = array();
		$json['materia'] = array();
		
		foreach ($objectMateriaArray as $i => $objectMateria){
			
			$atributos = $objectMateria->getArrayAtributos();
			
			foreach ($atributos as $index => $atributo){

				$json['materia'][$i][$index] = $atributo;

			}			
		} 
		//print_r($json);
		echo json_encode($json);
	}
}
?>